﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace Server.MessageModule.Message
{
    public class SensorMessage : BaseNetworkMessage
    {
        private Dictionary<string, float> _accel = new Dictionary<string, float>();
        private Dictionary<string, float> _magOrient = new Dictionary<string, float>();

        public Dictionary<string, float> Accel { get { return _accel; } set { _accel = value; } }
        public Dictionary<string, float> MagOrientation { get { return _magOrient; } set { _magOrient = value; } }


        public SensorMessage()
            : base(ShareMacro.MESSAGETYPE_SENSOR)
        {

        }

        public override string Serialize()
        {
            return null;
        }

        public override void Deserialize(string data)
        {
            Dictionary<string, object> dic = JsonConvert.DeserializeObject<Dictionary<string, object>>(data);
            if (dic == null)
                throw new Exception("Null pointer exeption!");
            _accel = null;
            _accel = JsonConvert.DeserializeObject<Dictionary<string, float>>(dic[ShareMacro.TAG_ACCELER].ToString());
            _magOrient = null;
            _magOrient = JsonConvert.DeserializeObject<Dictionary<string, float>>(dic[ShareMacro.TAG_MAGORIENT].ToString());
        }
    }
}
